// FindEye.h: interface for the CFindEye class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(NLPR_FINDEYE_HL)
#define NLPR_FINDEYE_HL

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

struct EyeModel_HL
{
	int m_nMaxLayNum;	// MaxLayerNum
	int maxT;		    // MaxFeatureNum

	int *cascade;
	double *finalthreshold;
	int (*finaltype)[3];
	double *finalh;
	int *finalsign;
	double *errorset;
	int *featureset;	
	int (*featurescale)[4];
	double *apha;

};

#define NULL_POINTER(x) x = NULL
#define SAFE_RELEASE(x) if(x) {delete x; x = NULL;}

class CFindEye_HL  
{
public:
	void SAFE_RELEASE_EYE_MODEL(EyeModel_HL* pModel);
	BOOL LoadOneModelFromFile(EyeModel_HL* *m_ppModel, CString szModelFileName);
	BOOL LoadOneModelFromResource(EyeModel_HL **m_ppModel);
	BOOL LoadModelFromFile();
	inline bool DcEyes(int PosX,int PosY,double* mScore);
	void GetEyePix(BYTE **pOriImage, int Width, int Height,RECT DetectedFace,POINT* templ,POINT* tempr);
	CFindEye_HL();
	virtual ~CFindEye_HL();
public:
	inline void GetItgImage(int **pItgImage,BYTE **pImage, int ImageWidth, int ImageHeight);
	inline int GetFeatureValue(int **ppItgImage,int mm,int x,int y);
	inline double GetFilterValueWithImage(int **ppzlImageData, int FilterNo, int RECTWidth,int Posx,int Posy,int StartX, int StartY);
	void SaveBmpImg(CString szFileName, BYTE **ppImg, int nWidth, int nHeight);
	
    int m_nMaxFilterNum;
    int m_nMaxLayerNum;
	BYTE** m_ppGrayImg;
	int** m_ppItgImg;
	float  m_fConfThr[30000];
	EyeModel_HL* m_pModel;
	EyeModel_HL* m_pArrModel[10];
	int m_nModel;
	int m_nWidth;
	int m_nHeight;
//	Pix L_EYE;
//	Pix R_EYE;
	int SubWindowWidth;
	int SubWindowHeight;
	int m_nFeatureNum;
	int m_nMaxFeatureNum;
	double m_fRatio;
	int m_nFilterNum;
	int m_nLayer;
	int m_nStep;
private:
	void SAFE_RELEASE300(unsigned char** ppImg, int nDim);
	void SAFE_RELEASE30(int** ppImg, int nDim);
};

#endif // !defined(AFX_FINDEYE_H__EEF2A4BC_22BE_4747_A95C_6165260607C3__INCLUDED_)
